import 'package:flutter/material.dart';

// 局部刷新
class LearnStreamPage extends StatefulWidget {
  @override
  _LearnStreamPageState createState() => _LearnStreamPageState();
}

class _LearnStreamPageState extends State<LearnStreamPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("局部刷新Stream"),
      ),
      body: Center(
        child: StreamBuilder<String>(
          initialData: "起始",
          stream: Stream.periodic(Duration(seconds: 1), (index) {
            return DateTime.now().toIso8601String();
          }),
          builder: (context, snapshot) {
            return Text(
              '${snapshot.data}',
              style: TextStyle(fontSize: 20),
            );
          },
        ),
      ),
    );
  }
}
